package com.listeningframework.boot.autoconfigure.orm.jpa.support;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Listening JPA Entity Key
 * 
 * @author listening
 * @version $Id: ListeningJpaEntityKey.java, v 0.1 2015年5月1日 下午5:44:31 listening Exp $
 */
@MappedSuperclass
public abstract class ListeningJpaEntityKey implements Serializable {
    /**  */
    private static final long serialVersionUID = 8884655340971161058L;

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    protected Long            id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void treatBlankId() {
        if (id != null && id == 0) {
            setId(null);
        }
    }

    public boolean isCreate() {
        return id == null;
    }
}
